import request from '@/hooks/request'
// 1 简易 2 专业  报价规则
const Api = {
  add: '/platform/quotation/common/addQuotationGroup', //新增报价模板
  list: '/platform/quotation/common/getQuotationGroupList', //获取简易报价的列表
  del: '/platform/quotation/common/delectQuotationGroup', //删除当前的模板
  edit: '/platform/quotation/common/editQuotationGroup', //编辑当前的模板
  Rulelist: '/platform/simpleQuotation/getGroupSimpleQuotationList', //获取报价规则列表
  deleteRule: '/platform/simpleQuotation/deleteGroupSimpleQuotation', //删除模板中的规则
  addTemplateRule: '/platform/simpleQuotation/addGroupSimpleQuotation', //添加模板中的规则
  editTemplateRule: '/platform/simpleQuotation/editGroupSimpleQuotation', //编辑模板中的规则
  pushRule: '/platform/simpleQuotation/simpleGroupQuotationPushRobots', //推送模板给闲鱼店铺账号
  //专业
  ruleListzy: '/platform/quotationRule/getGroupQuotationRuleList', //获取专业的报价规则列表
  deleteRulezy: '/platform/quotationRule/deleteGroupQuotationRule', //删除模板中的规则
  addTemplateRulezy: '/platform/quotationRule/addGroupQuotationRule', //添加模板中的规则
  editTemplateRulezy: '/platform/quotationRule/editGroupQuotationRule', //编辑模板中的规则
  pushZyRuleTemplate: '/platform/quotationRule/quotationRuleGroupPushRobots', //推送模板给闲鱼店铺账号
  //添加模板
 installGroupQuotationRule: "/platform/quotationRule/installGroupQuotationRule",// 设置专业报价规则模板

  installGroupSimpleQuotation: '/platform/simpleQuotation/installGroupSimpleQuotation', // 设置报价规则模板
}

export const installGroupSimpleQuotation = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.installGroupSimpleQuotation,
    data: parameter,
  })
}

export const installGroupQuotationRule = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.installGroupQuotationRule,
    data: parameter,
  })
}

export const addTemplate = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.add,
    data: parameter,
  })
}

export const EditTemplate = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.edit,
    data: parameter,
  })
}
export const getSimpleTemplateList = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('type', parameter.type)
  return request({
    method: 'post',
    url: Api.list,
    data: formData,
  })
}
export const deleteTemplate = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('type', parameter.type)
  formData.append('id', parameter.id)

  return request({
    method: 'post',
    url: Api.del,
    data: formData,
  })
}
export const getSimpleRuleList = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.Rulelist,
    data: parameter,
  })
}

export const deleteTemplateRule = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('groupId', parameter.groupId)
  formData.append('id', parameter.id)

  return request({
    method: 'post',
    url: Api.deleteRule,
    data: formData,
  })
}

export const addTemplateRule = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.addTemplateRule,
    data: parameter,
  })
}
export const editTemplateRule = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.editTemplateRule,
    data: parameter,
  })
}

export const pushTemplate = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.pushRule,
    data: parameter,
  })
}

export const getListByZyRuleList = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.ruleListzy,
    data: parameter,
  })
}

export const deleteTemplateZyRule = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('groupId', parameter.groupId)
  formData.append('id', parameter.id)

  return request({
    method: 'post',
    url: Api.deleteRulezy,
    data: formData,
  })
}

export const addTemplateZyRule = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.addTemplateRulezy,
    data: parameter,
  })
}
export const editTemplateZyRule = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.editTemplateRulezy,
    data: parameter,
  })
}

export const pushTemplateZyRule = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.pushZyRuleTemplate,
    data: parameter,
  })
}

